Page({
    data: {
        order: [],
        activeKey: 0,
        state: 0,
        type: -1,
        NavigationBarTitle: ['我的发布', '我的接单', '我的收藏']
    },

    onLoad(e) {
        console.log('PCT onload')
        this.setData({
            order: JSON.parse(e.order),
            type: e.type
        })
        wx.setNavigationBarTitle({
            title: this.data.NavigationBarTitle[e.type]
        })
        // 如果是我的接单，默认选中已接单标签
        if (e.type == 1) {
            this.setData({
                activeKey: 1,
                state: 1
            })
        }
    },

    onChange(event) {
        this.setData({
            state: event.detail
        })
    },

    toDetail(e) {
        console.log(e.currentTarget.dataset.item)
        let orderDetail = e.currentTarget.dataset
        wx.setStorage({
            key: 'orderDetail',
            data: orderDetail,
            success: (res) => {
                wx.navigateTo({
                    url: `/pages/orderDetail/orderDetail?type=${this.data.type}`,
                });
            }
        });
    }
})